import token

import requests

from com.yh.utils.utils import oa_host


class Post():

    def getPostList(self,pageNum=1,pageSize=10,postCode="",postName="",status="",token=""):
        post = {
            "pageNum":pageNum,
            "pageSize":pageSize,
            "postCode":postCode,
            "postName":postName,
            "status":status,
        }
        resp = requests.get(oa_host+"/system/post/list", params=post,headers=token)
        return resp

    #新增岗位
    def addPost(self,postCode,postName,postSort=1,status=0,token=""):
        addpost =  {
                "postCode": postCode,
                "postName": postName,
                "postSort": postSort,
                "status": status
            }
        resp = requests.post(oa_host+"/system/post", json=addpost,headers=token)
        return resp

    #修改岗位
    def updataPost(self,
                searchValue = None,
                createBy="admin",
                createTime="2025-09-10 20:23:27",
                updateBy= None,
                updateTime=None,
                remark=None,
                params= {},
                postId=8,
                postCode="",
                postName="",
                postSort=1,
                status= "0",
                flag= False,token=""):

        updatapost =  {
                "searchValue":searchValue,
                "createBy": createBy,
                "createTime": createTime,
                "updateBy": updateBy,
                "updateTime":updateTime,
                "remark": remark,
                "params": params,
                "postId":postId,
                "postCode": postCode,
                "postName": postName,
                "postSort": postSort,
                "status": status,
                "flag": flag,
            }
        resp = requests.put(oa_host+"/system/post", json=updatapost,headers=token)
        return resp
    #导出为excel
    def postExcel(self,pageNum,pageSize,token=""):

        postexcel = {
            "pageNum":pageNum,
            "pageSize":pageSize
        }
        resp = requests.get(oa_host+"/system/post/export", params=postexcel,headers=token)
        return resp

    #获取岗位选择框列表
    def postOptionselect(self):

        resp = requests.get(oa_host+"/system/post/optionselect",headers=token)
        return resp

    #删除岗位
    def delPost(self,postId,token=""):
        delpost = { "postId":postId }

        resp = requests.delete(oa_host+"/system/post",params=delpost,headers=token)
        return resp

    #根据岗位编号获取信息
    def idPost(self,postId,token=""):
        idpost = { "postId":postId }

        resp = requests.get(oa_host+"/system/post",params=idpost,headers=token)
        return resp




